import axios from 'axios'
import config from '@/config.js'

const api = axios.create({
    baseURL: config.apiUrl,
    timeout: 5000,
    headers: {
        'Content-Type': 'multipart/form-data'
    }
})

// 登录
export const login = (data) => {
    const formData = new FormData()
    formData.append('username', data.username)
    formData.append('password', data.password)
    return api.post('/user/signin', formData)
}

// 注册
export const register = (data) => {
    const formData = new FormData()
    formData.append('username', data.username)
    formData.append('password', data.password)
    formData.append('email', data.email)
    return api.post('/user/signup', formData)
}